home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performMirrorJoint.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  9.3 KB  |  406 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  25 April 1997
  22. //
  23. //  Description:
  24. //        This script provides an option box dialog for the mirrorJoint command.
  25. //
  26. //    Input Arguments:
  27. //        boolean showOptionBox    true - show the option box dialog
  28. //                                false - just execute the command
  29. //
  30.  
  31. //  Procedure Name:
  32. //      setOptionVars
  33. //
  34. //  Description:
  35. //        Initialize the option values.
  36. //
  37. //  Input Arguments:
  38. //        Whether to set the options to default values.
  39. //
  40. //  Return Value:
  41. //      None.
  42. //
  43. proc setOptionVars(int $forceFactorySettings)
  44. {
  45.     //    Mode.
  46.     //
  47.     if ($forceFactorySettings || !`optionVar -exists mirrorJointMode`) {
  48.         optionVar -intValue mirrorJointMode 1;
  49.     }
  50.     if ($forceFactorySettings || !`optionVar -exists mirrorJointFunction`) {
  51.         optionVar -intValue mirrorJointFunction 1;
  52.     }
  53.     if ($forceFactorySettings || !`optionVar -exists mirrorJointSearch`) {
  54.         optionVar -stringValue mirrorJointSearch "";
  55.     }
  56.     if ($forceFactorySettings || !`optionVar -exists mirrorJointReplace`) {
  57.         optionVar -stringValue mirrorJointReplace "";
  58.     }
  59. }
  60.  
  61. //
  62. //  Procedure Name:
  63. //      mirrorJointSetup
  64. //
  65. //  Description:
  66. //        Update the state of the option box UI to reflect the option values.
  67. //
  68. //  Input Arguments:
  69. //      parent               - Top level parent layout of the option box UI.
  70. //                             Required so that UI object names can be 
  71. //                             successfully resolved.
  72. //
  73. //        forceFactorySettings - Whether the option values should be set to
  74. //                             default values.
  75. //
  76. //  Return Value:
  77. //      None.
  78. //
  79. global proc mirrorJointSetup(string $parent, int $forceFactorySettings)
  80. {
  81.     //    Retrieve the option settings
  82.     //
  83.     setOptionVars($forceFactorySettings);
  84.  
  85.     setParent $parent;
  86.  
  87.     //    Query the optionVar's and set the values into the controls.
  88.  
  89.     //    Mode.
  90.     //
  91.     radioButtonGrp -edit 
  92.         -select `optionVar -query mirrorJointMode`
  93.         mirrorJointMode;
  94.  
  95.     //    Function.
  96.     //
  97.     radioButtonGrp -edit 
  98.         -select `optionVar -query mirrorJointFunction`
  99.         mirrorJointFunction;
  100.  
  101.     string $search = `optionVar -query mirrorJointSearch`;
  102.     if (`textFieldGrp -exists mirrorJointSearchName`) {
  103.         textFieldGrp -e -tx $search mirrorJointSearchName;
  104.     }
  105.     string $replace = `optionVar -query mirrorJointReplace`;
  106.     if (`textFieldGrp -exists mirrorJointReplaceName`) {
  107.         textFieldGrp -e -tx $replace mirrorJointReplaceName;
  108.     }
  109. }
  110.  
  111. //
  112. //  Procedure Name:
  113. //      mirrorJointCallback
  114. //
  115. //  Description:
  116. //        Update the option values with the current state of the option box UI.
  117. //
  118. //  Input Arguments:
  119. //      parent - Top level parent layout of the option box UI.  Required so
  120. //               that UI object names can be successfully resolved.
  121. //
  122. //        doIt   - Whether the command should execute.
  123. //
  124. //  Return Value:
  125. //      None.
  126. //
  127. // ********* Change 'mirrorJoint' in this proc to be the name of your command
  128. global proc mirrorJointCallback(string $parent, int $doIt)
  129. {
  130.     setParent $parent;
  131.  
  132.     //    Set the optionVar's from the control values, and then
  133.     //    perform the command.
  134.  
  135.     //    Mode.
  136.     //
  137.     optionVar -intValue mirrorJointMode
  138.         `radioButtonGrp -query -select mirrorJointMode`;
  139.  
  140.     //    Founction.
  141.     //
  142.     optionVar -intValue mirrorJointFunction
  143.         `radioButtonGrp -query -select mirrorJointFunction`;
  144.  
  145.     optionVar -stringValue mirrorJointSearch
  146.         `textFieldGrp -query -tx mirrorJointSearchName`;
  147.  
  148.     optionVar -stringValue mirrorJointReplace
  149.         `textFieldGrp -query -tx mirrorJointReplaceName`;
  150.  
  151.     if ($doIt) {
  152.         performMirrorJoint 0; 
  153.         addToRecentCommandQueue "performMirrorJoint 0" "MirrorJoint";
  154.     }
  155. }
  156.  
  157. //
  158. //  Procedure Name:
  159. //      mirrorJointOptions
  160. //
  161. //  Description:
  162. //        Construct the option box UI.  Involves accessing the standard option
  163. //        box and customizing the UI accordingly.
  164. //
  165. //  Input Arguments:
  166. //      None.
  167. //
  168. //  Return Value:
  169. //      None.
  170. //
  171. proc mirrorJointOptions()
  172. {
  173.     //    Name of the command for this option box.
  174.     //
  175.     string $commandName = "mirrorJoint";
  176.  
  177.     //    Build the option box actions.
  178.     //
  179.     string $callback = ($commandName + "Callback");
  180.     string $setup = ($commandName + "Setup");
  181.  
  182.     //    Get the option box.
  183.     //
  184.     string $layout = getOptionBox();
  185.     setParent $layout;
  186.     
  187.     //    Pass the command name to the option box.
  188.     //
  189.     setOptionBoxCommandName($commandName);
  190.     
  191.     //    Activate the default UI template.
  192.     //
  193.     setUITemplate -pushTemplate DefaultTemplate;
  194.  
  195.     //    Turn on the wait cursor.
  196.     //
  197.     waitCursor -state 1;
  198.  
  199.     tabLayout -scr true -tv false;
  200.     string $parent = `columnLayout -adjustableColumn 1`;
  201.     
  202.     radioButtonGrp -label "Mirror Across"
  203.         -numberOfRadioButtons 3
  204.         -label1 "XY"
  205.         -label2 "YZ"
  206.         -label3 "XZ"
  207.         -select 1
  208.         mirrorJointMode;
  209.  
  210.     radioButtonGrp -label "Mirror Function"
  211.         -numberOfRadioButtons 2
  212.         -label1 "Behavior"
  213.         -label2 "Orientation"
  214.         -select 1
  215.         mirrorJointFunction;
  216.  
  217.     separator;
  218.     text -align "left" -label "    Replacement names for duplicated joints:";
  219.     textFieldGrp -label "Search For:" -tx "" mirrorJointSearchName;
  220.     textFieldGrp -label "Replace With:" -tx "" mirrorJointReplaceName;    
  221.             
  222.     //    Turn off the wait cursor.
  223.     //
  224.     waitCursor -state 0;
  225.     
  226.     //    Deactivate the default UI template.
  227.     //
  228.     setUITemplate -popTemplate;
  229.  
  230.     //    'Apply' button.
  231.     //
  232.     string $applyBtn = getOptionBoxApplyBtn();
  233.     button -edit
  234.         -l "Mirror"
  235.         -command ($callback + " " + $parent + " " + 1)
  236.         $applyBtn;
  237.  
  238.     //    'Save' button.
  239.     //
  240.     string $saveBtn = getOptionBoxSaveBtn();
  241.     button -edit 
  242.         -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox")
  243.         $saveBtn;
  244.  
  245.     //    'Reset' button.
  246.     //
  247.     string $resetBtn = getOptionBoxResetBtn();
  248.     button -edit 
  249.         -command ($setup + " " + $parent + " " + 1)
  250.         $resetBtn;
  251.  
  252.     //    Set the option box title.
  253.     //
  254.     setOptionBoxTitle("Mirror Joint Options");
  255.  
  256.     //    Customize the 'Help' menu item.
  257.     //
  258.     setOptionBoxHelpTag( "MirrorJoint" );
  259.  
  260.     //    Set the current values of the option box.
  261.     //
  262.     eval (($setup + " " + $parent + " " + 0));    
  263.     
  264.     //    Show the option box.
  265.     //
  266.     showOptionBox();
  267. }
  268.  
  269. //
  270. //  Procedure Name:
  271. //      mirrorJointHelp
  272. //
  273. //  Description:
  274. //        Return a short description about this command.
  275. //
  276. //  Input Arguments:
  277. //      None.
  278. //
  279. //  Return Value:
  280. //      string.
  281. //
  282. proc string mirrorJointHelp()
  283. {
  284.     return 
  285.     "  Command: mirrorJoint - mirrors two skeletons.\n" +
  286.     "Selection: joints";    
  287. }
  288.  
  289. //
  290. //  Procedure Name:
  291. //      assembleCmd
  292. //
  293. //  Description:
  294. //        Construct the command that will apply the option box values.
  295. //
  296. //  Input Arguments:
  297. //      None.
  298. //
  299. //  Return Value:
  300. //      None.
  301. //
  302. proc string assembleCmd()
  303. {
  304.     string $cmd = "mirrorJoint";
  305.  
  306.     setOptionVars(false);
  307.  
  308.     string $mode;
  309.     int $selection = `optionVar -query mirrorJointMode`;
  310.     switch ($selection) {
  311.         case 1:
  312.             $mode = " -mirrorXY";
  313.             break;
  314.         case 2:
  315.             $mode = " -mirrorYZ";
  316.             break;
  317.         case 3:
  318.             $mode = " -mirrorXZ";
  319.             break;
  320.     }
  321.  
  322.     $cmd = ($cmd + $mode);
  323.  
  324.     string $func;
  325.     $selection = `optionVar -query mirrorJointFunction`;
  326.     switch ($selection)
  327.     {
  328.         case 1:
  329.             $func = " -mirrorBehavior";
  330.             $cmd = ($cmd + $func);
  331.             break;
  332.     }
  333.  
  334.     string $search = `optionVar -query mirrorJointSearch`;
  335.     string $replace = `optionVar -query mirrorJointReplace`;
  336.     if (size($search) > 0 && size($replace) > 0) {
  337.         $cmd += (" -searchReplace \""+$search+"\" \""+$replace+"\"");
  338.     }
  339.     
  340.     return $cmd;
  341. }
  342.  
  343. //
  344. //  Procedure Name:
  345. //      performMirrorJoint
  346. //
  347. //  Description:
  348. //        Perform the mirrorJoint command using the corresponding 
  349. //        option values.  This procedure will also show the option box
  350. //        window if necessary as well as construct the command string
  351. //        that will invoke the mirrorJoint command with the current
  352. //        option box values.
  353. //
  354. //  Input Arguments:
  355. //      0 - Execute the command.
  356. //      1 - Show the option box dialog.
  357. //      2 - Return the command.
  358. //
  359. //  Return Value:
  360. //      None.
  361. //
  362. global proc string performMirrorJoint(int $action)
  363. {
  364.     string $cmd = "";
  365.  
  366.     switch ($action) {
  367.  
  368.         //    Execute the command.
  369.         //
  370.         case 0:
  371.             //    Retrieve the option settings
  372.             //
  373.             setOptionVars(false);
  374.  
  375.             //    Get the command.
  376.             //
  377.             $cmd = `assembleCmd`;
  378.  
  379.             //    Execute the command with the option settings.
  380.             //
  381.             evalEcho($cmd);
  382.  
  383.             break;
  384.  
  385.         //    Show the option box.
  386.         //
  387.         case 1:
  388.             mirrorJointOptions;
  389.             break;
  390.  
  391.         //    Return the command string.
  392.         //
  393.         case 2:
  394.             //    Retrieve the option settings.
  395.             //
  396.             setOptionVars (false);
  397.  
  398.             //    Get the command.
  399.             //
  400.             $cmd = `assembleCmd`;
  401.             break;
  402.     }
  403.     return $cmd;
  404. }
  405.  
  406.